package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Dearsil
 * @Date: 2025/1/3 14:48
 * @Version: 1.0
 * @Description: Hello Description!
 */
@RestController("operationActivityController")
@RequestMapping("/operation/activity")
@Api(tags = "运营端 - 优惠券活动相关接口")
public class ActivityController {
    @Autowired
    private IActivityService activityService;

    //新增或者修改优惠券活动
    @PostMapping("/save")
    public void save(@RequestBody ActivitySaveReqDTO activitySaveReqDTO){
        activityService.saveOrUpdateActivity(activitySaveReqDTO);
    }

    //运营端分页查询活动
    @GetMapping("/page")
    public PageResult<ActivityInfoResDTO> findByPage(ActivityQueryForPageReqDTO dto) {
        return activityService.findByPage(dto);
    }

    //查询活动详情
    @GetMapping("/{id}")
    public ActivityInfoResDTO getDetail(@PathVariable("id") Long id) {
        return activityService.findById(id);
    }

    //活动撤销
    @PostMapping("/revoke/{id}")
    public void revoke(@PathVariable("id") Long id) {
        activityService.revoke(id);
    }

}
